package com.lsw.jgyf.ui.activity;

import android.content.Intent;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.lsw.jgyf.R;
import com.lsw.jgyf.ui.base.activity.BaseActivity;

import butterknife.BindView;

/**
 * Created by lsw on 2018/7/8.
 */

public class LoginActivity extends BaseActivity<LoginPresenter> implements View.OnClickListener, LoginContract.View {
    @BindView(R.id.tv_change_pass)
    TextView tv_change_pass;
    @BindView(R.id.iv_phone_login)
    ImageView iv_phone_login;
    @BindView(R.id.tv_register)
    TextView tv_register;
    @BindView(R.id.et_phone)
    EditText et_phone;
    @BindView(R.id.et_pass)
    EditText et_pass;
    @BindView(R.id.tv_login)
    TextView tv_login;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_login;
    }

    @Override
    protected void initInjector() {
        mActivityComponent.inject(this);
    }

    @Override
    protected void initEventAndData() {
        tv_change_pass.setOnClickListener(this);
        iv_phone_login.setOnClickListener(this);
        tv_register.setOnClickListener(this);
        tv_login.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_change_pass:
                Intent intent = new Intent(mContext, ForgetPasswordActivity.class);
                startActivity(intent);
                break;
            case R.id.iv_phone_login:
                Intent intent1 = new Intent(mContext, PhoneLoginActivity.class);
                startActivity(intent1);
                break;
            case R.id.tv_register:
                Intent intent2 = new Intent(mContext, RegisterActivity.class);
                startActivity(intent2);
                break;
            case R.id.tv_login:
                mPresenter.Login(et_phone.getText().toString().trim(), et_pass.getText().toString().trim());
                break;
        }
    }

    @Override
    public void setData() {

    }

    @Override
    public void loginSucceed() {
        Intent intent = new Intent(mContext, MainActivity.class);
        startActivity(intent);
        finish();
    }
}
